#include "main.h"
#include "stm32h7xx_hal.h"

SPI_HandleTypeDef hspi1;

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void);

int main(void)
{
    uint8_t rx_data = 0;
    /* MCU初始化代码 */
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_SPI1_Init();

    while (1) {
        if (HAL_SPI_Receive(&hspi1, &rx_data, 1, 1000) == HAL_OK) {
            printf("Received data: 0x%x\n", rx_data);
            rx_data = rx_data + 1;
            HAL_SPI_Transmit(&hspi1, &rx_data, 1, 1000);
        }
    }
}
